
const _stack = new WeakMap()
const _minStack = new WeakMap()

var MinStack = function() {
    _stack.set(this, []);
    _minStack.set(this, []);
};

/** 
 * @param {number} val
 * @return {void}
 */
MinStack.prototype.push = function(val) {
    const stack = _stack.get(this);
    const minStack = _minStack.get(this);
    stack.push(val)
    if(minStack.length === 0 || minStack[minStack.length - 1] >= val) {
        minStack.push(val)
    }
};

/**
 * @return {void}
 */
MinStack.prototype.pop = function() {
    const stack = _stack.get(this);
    const minStack = _minStack.get(this);
    const val = stack.pop();
    if(minStack[minStack.length - 1] === val) {
        minStack.pop();
    }
};

/**
 * @return {number}
 */
MinStack.prototype.top = function() {
    const stack = _stack.get(this);
    return stack[stack.length - 1];
};

/**
 * @return {number}
 */
MinStack.prototype.getMin = function() {
    const minStack = _minStack.get(this);
    return minStack[minStack.length - 1];
};

var obj = new MinStack()
obj.push(-2)
obj.push(0)
obj.push(-3)
var param_1 = obj.getMin()
obj.pop()
var param_2 = obj.top()
var param_3 = obj.getMin()
console.log(param_1)
console.log(param_2)
console.log(param_3)
/** 
 * Your MinStack object will be instantiated and called as such:
 * var obj = new MinStack()
 * obj.push(val)
 * obj.pop()
 * var param_3 = obj.top()
 * var param_4 = obj.getMin()
 */